package framework.ui 
{
	import com.greensock.TweenLite;
	import flash.display.MovieClip;
	import flash.text.TextField;
	import framework.FrameworkAdmin;
	import framework.layer.LayerManager;
	import framework.util.mc.MCUtil;
	import Global.GConfig;
	
	/**
	 * 文字提示
	 * * @author fly
	 */
	public class Tiptext
	{
		private static var _tipText:Tiptext;
		
		private var _tween:TweenLite;
		
		private var _view:MovieClip;
		
		public function Tiptext(str:String , _x:int = 0, _y:int = 0 , delayTime:int = 1) 
		{
			_tipText = this;
			_view = FrameworkAdmin.instance.getMovieClip("TipText");
			var txt:TextField = _view.text;
			txt.height = 150;
			txt.htmlText = "<b>"+str +"</b>";
			LayerManager.instance.addToLayer(LayerManager.TEXT_TIPS, _view);
			
			_view.x = GConfig.SCREEN_W / 2 + _x;
			_view.y = GConfig.SCREEN_H / 2 - 100 + _y;
			
			_tween = TweenLite.to(_view, 2, { alpha:0, delay:delayTime , 
						onComplete:function():void { clear(); }} );
		}
		
		public function clear():void
		{
			TweenLite.killTweensOf(_tween.target);
			_tween = null;
			_view.text.text = "";
			_view.parent && _view.parent.removeChild(_view);
			MCUtil.removeAllChild(_view);
			_view = null;
			_tipText = null;
		}
		
	}
	
}